//
//  MKReaderConst.swift
//  Fanmugua
//
//  Created by MK on 2021/3/29.
//  Copyright © 2021 taolang. All rights reserved.
//

import UIKit

let MKReaderBottomViewHeight:CGFloat = 80+SCREEN_SAVE_BOTTOM_HEIGHT
let MKReaderBottomViewHeightNoComment:CGFloat = 60+SCREEN_SAVE_BOTTOM_HEIGHT

let CG_RESPONSE_STATUS_400:Int = 400
let CG_RESPONSE_STATUS_401:Int = 401    // token 失效
let CG_RESPONSE_STATUS_900:Int = 900    // X币不足，需充值
let CG_RESPONSE_STATUS_901:Int = 901    // 免费长漫需要看广告
let CG_RESPONSE_STATUS_902:Int = 902    // 本书完结
let CG_RESPONSE_STATUS_903:Int = 903    // 本书未完结，等待更新
let CG_RESPONSE_STATUS_904:Int = 904    // 小说/章节 不存在
let CG_RESPONSE_STATUS_905:Int = 905    // 小说/章节 不存在


// Key - 配置
let MKREADER_KEY_CONFIGURE:String = "MKREADER_KEY_CONFIGURE"
// Key - 阅读对象
let MKREADER_KEY_OBJECT:String = "MKREADER_KEY_OBJECT"
// Key - 阅读记录
let MKREADER_KEY_RECORD:String = "MKREADER_KEY_RECORD"


//阅读风格颜色
let MKREADER_COLOR_1_BG:UIColor             = RGBA(246, 246, 246)
let MKREADER_COLOR_1_TEXT:UIColor           = RGBA(41, 41, 41)

let MKREADER_COLOR_2_BG:UIColor             = RGBA(248, 238, 229)
let MKREADER_COLOR_2_TEXT:UIColor           = RGBA(46, 34, 7)

let MKREADER_COLOR_3_BG:UIColor             = RGBA(244, 220, 176)
let MKREADER_COLOR_3_TEXT:UIColor           = RGBA(102, 61, 37)

let MKREADER_COLOR_4_BG:UIColor             = RGBA(223, 242, 223, 1)
let MKREADER_COLOR_4_TEXT:UIColor           = RGBA(20, 32, 22)

let MKREADER_COLOR_5_BG:UIColor             = RGBA(24, 24, 24)
let MKREADER_COLOR_5_TEXT:UIColor           = RGBA(180, 180, 180)

//var MKREADER_COLOR_MAIN:UIColor = UIColor.theme;
let MKREADER_BG_COLORS:[UIColor] = [MKREADER_COLOR_1_BG,
                                    MKREADER_COLOR_2_BG,
                                    MKREADER_COLOR_3_BG,
                                    MKREADER_COLOR_4_BG,
                                    MKREADER_COLOR_5_BG]

let MKREADER_TEXT_COLORS:[UIColor] = [MKREADER_COLOR_1_TEXT,
                                      MKREADER_COLOR_2_TEXT,
                                      MKREADER_COLOR_3_TEXT,
                                      MKREADER_COLOR_4_TEXT,
                                      MKREADER_COLOR_5_TEXT]


//行间距
let MKREADER_TEXT_SPACE_SMALL:CGFloat       = 5
let MKREADER_TEXT_SPACE_MIDDLE:CGFloat      = 7
let MKREADER_TEXT_SPACE_BIG:CGFloat         = 15

//行间距
let MKREADER_TEXT_LINE_SPACE_MIN:NSInteger         = 16
let MKREADER_TEXT_LINE_SPACE_MAX:NSInteger         = 32
let MKREADER_TEXT_LINE_SPACE_DEFAULT:NSInteger     = 16
let MKREADER_TEXT_LINE_SPACE_SPACE:NSInteger       = 2
//字间距
let MKREADER_TEXT_CHARACTER_SPACE_MIN:NSInteger         = 0
let MKREADER_TEXT_CHARACTER_SPACE_MAX:NSInteger         = 0
let MKREADER_TEXT_CHARACTER_SPACE_DEFAULT:NSInteger     = 0
let MKREADER_TEXT_CHARACTER_SPACE_SPACE:NSInteger       = 0
//段间距
let MKREADER_TEXT_PARAGRAPH_SPACE_MIN:NSInteger         = 18
let MKREADER_TEXT_PARAGRAPH_SPACE_MAX:NSInteger         = 34
let MKREADER_TEXT_PARAGRAPH_SPACE_DEFAULT:NSInteger     = 18
let MKREADER_TEXT_PARAGRAPH_SPACE_SPACE:NSInteger       = 2

//段落间距
let MKREADER_PARAGRAPH_SPACE_SMALL:CGFloat  = 10
let MKREADER_PARAGRAPH_SPACE_MIDDLE:CGFloat = 15
let MKREADER_PARAGRAPH_SPACE_BIG:CGFloat    = 20

func MKREADER_CHAPTER_NAME(_ name:String) -> String { return "\n\(name)\n\n" }

// 段落头部双圆角空格 PH : Paragraph prefix
let MKREADER_PH_SPACE:String = "　　"

//字体大小
let MKREADER_FONT_SIZE_MIN:NSInteger = 12       //最小
let MKREADER_FONT_SIZE_MAX:NSInteger = 28       //最大
let MKREADER_FONT_SIZE_DEFAULT:NSInteger = 20   //默认
let MKREADER_FONT_SIZE_SPACE:NSInteger = 4      //叠加指数

//章节标题 - 在当前字体大小上叠加指数
let MKREADER_TITLE_FONT_SIZE_SPACE:NSInteger = 8

//阅读范围 top height
var MKREADER_STATUS_TOP_HEIGHT:CGFloat! { return NAVGATION_VIEW_HEIGHT }
//阅读范围 bottom height
var MKREADER_STATUS_BOTTOM_HEIGHT:CGFloat! = 50
//阅读范围(阅读顶部状态栏 + 阅读View + 阅读底部状态栏)
var MKREADER_TEXT_RECT:CGRect! {
    return CGRect(x: 16,
                  y: MKREADER_STATUS_TOP_HEIGHT,
                  width: SCREEN_WIDTH - 32,
                  height: SCREEN_HEIGHT - MKREADER_STATUS_TOP_HEIGHT - 64) //MKREADER_STATUS_BOTTOM_HEIGHT
}

// 没有章节了(可以指定为任意标识,默认是空则为没有更多章节)
let MKREADER_NO_MORE_CHAPTER:NSNumber! = nil
// 书籍首页-书名页
let MKREADER_BOOK_HOME_PAGE:NSInteger = -1
// 动画时间
let MKREADER_ANIMATE_DURATION:TimeInterval = 0.3







//// 用于指定章节最后一页
//let MKREADER_LAST_PAGE:NSInteger = -1






//
//// 阅读范围(阅读顶部状态栏 + 阅读View + 阅读底部状态栏)
//var MKREADER_TEXT_RECT:CGRect! {
//    return CGRect(x: 16,
//                  y: MKREADER_STATUS_TOP_HEIGHT,
//                  width: SCREEN_WIDTH - 32,
//                  height: SCREEN_HEIGHT - MKREADER_STATUS_TOP_HEIGHT - MKREADER_STATUS_BOTTOM_HEIGHT)
//}
//
//// 阅读View范围
////var MKREADER_VIEW_RECT:CGRect! {
////    let rect = MKREADER_RECT!
////    return CGRect(x: rect.minX,
////                  y: rect.minY + MKREADER_STATUS_TOP_VIEW_HEIGHT,
////                  width: rect.width,
////                  height: rect.height - MKREADER_STATUS_TOP_VIEW_HEIGHT - MKREADER_STATUS_BOTTOM_VIEW_HEIGHT)
////}
//
//
//
//
func SA_SIZE(_ size:CGFloat) -> CGFloat{
    return size
//    return size * (SCREEN_WIDTH / 375.0)
}
//func SA(is45:CGFloat, _ other:CGFloat) ->CGFloat {
//    return SA(is45, other, other, other, other)
//}
//func SA(isX:CGFloat, _ other:CGFloat) ->CGFloat {
//    return SA(isX_XS: isX, isX, other)
//}
//func SA(is45:CGFloat, _ isX_XS:CGFloat, _ isXR_XSMAX:CGFloat,  _ other:CGFloat) ->CGFloat {
//    return SA(is45, other, other, isX_XS, isXR_XSMAX)
//}
//func SA(isX_XS:CGFloat, _ isXR_XSMAX:CGFloat, _ other:CGFloat) ->CGFloat {
//    return SA(other, other, other, isX_XS, isXR_XSMAX)
//}
//func SA(_ is45:CGFloat, _ is678:CGFloat, _ is678P:CGFloat, _ isX_XS:CGFloat, _ isXR_XSMAX:CGFloat) ->CGFloat {
//    if (IS_IPHONE_4 || IS_IPHONE_5) {
//        return is45
//    }else if IS_IPHONE_678 {
//        return is678
//    }else if IS_IPHONE_678_PLUS {
//        return is678P
//    }else if IS_IPHONE_X_XS || IS_IPHONE_XR || IS_IPHONE_12MINI || IS_IPHONE_12 {
//        return isX_XS
//    }else {
//        return isXR_XSMAX
//    }
//}
//
//func MKREADER_FONT_SA(_ size:CGFloat) -> UIFont {
//    return UIFont.systemFont(ofSize: SA_SIZE(size))
//}
//
//func MKREADER_FONT_BOLD_SA(_ size:CGFloat) -> UIFont {
//    return UIFont.boldSystemFont(ofSize: SA_SIZE(size))
//}
//
//
///// 总进度字符串
//func MKREADER_TOTAL_PROGRESS_STRING(progress:Float) -> String {
//    return String(format: "%.1f%%", (floor(progress * 1000) / 10))
//}
//
//// 计算总进度
//func MKREADER_TOTAL_PROGRESS(readerInfo:MKReaderModel!,recordInfo:MKReaderRecordModel!) -> Float {
//
//    // 当前阅读进度
//    var progress:Float = 0.0
//
//    // 临时检查
//    if readerInfo == nil || recordInfo == nil {
//        return progress
//    }
//
//    if recordInfo.isLastChapter && recordInfo.isLastPage { // 最后一章最后一页
//        progress = 1.0
//    }else{
//        // 当前章节在所有章节列表中的位置
//        let chapterIndex:Float = recordInfo.chapterInfo.priority.floatValue
//        // 章节总数量
//        let chapterCount:Float = Float(readerInfo.chapterSimpleInfos.count)
//        // 阅读记录首位置
//        let locationFirst:Float = recordInfo.locationFirst.floatValue
//        // 阅读记录内容长度
//        let fullContentLength:Float = Float(recordInfo.chapterInfo.fullContent.length)
//        // 获得当前阅读进度
//        progress = (chapterIndex / chapterCount + locationFirst / fullContentLength / chapterCount)
//    }
//    return progress
//}


//let MKREADER_COLOR_1_MENU_TEXT:UIColor      = RGBA(43, 43, 43)
//let MKREADER_COLOR_2_MENU_TEXT:UIColor      = RGBA(185, 132, 23)
//let MKREADER_COLOR_3_MENU_TEXT:UIColor      = RGBA(102, 61, 37)
//let MKREADER_COLOR_4_MENU_TEXT:UIColor      = RGBA(46, 138, 91)
//let MKREADER_COLOR_5_MENU_TEXT:UIColor      = RGBA(132, 132, 132)

//let MKREADER_MENU_TEXT_COLORS:[UIColor] = [MKREADER_COLOR_1_MENU_TEXT,
//                                           MKREADER_COLOR_2_MENU_TEXT,
//                                           MKREADER_COLOR_3_MENU_TEXT,
//                                           MKREADER_COLOR_4_MENU_TEXT,
//                                           MKREADER_COLOR_5_MENU_TEXT]

//let MKREADER_COLOR_1_MENU_BG:UIColor  = RGBA(255, 255, 255)
//let MKREADER_COLOR_2_MENU_BG:UIColor  = RGBA(251, 247, 244)
//let MKREADER_COLOR_3_MENU_BG:UIColor  = RGBA(240, 219, 188)
//let MKREADER_COLOR_4_MENU_BG:UIColor  = RGBA(228, 238, 229)
//let MKREADER_COLOR_5_MENU_BG:UIColor  = RGBA(38, 38, 38)

//let MKREADER_MENU_BG_COLORS:[UIColor] = [MKREADER_COLOR_1_MENU_BG,
//                                         MKREADER_COLOR_2_MENU_BG,
//                                         MKREADER_COLOR_3_MENU_BG,
//                                         MKREADER_COLOR_4_MENU_BG,
//                                         MKREADER_COLOR_5_MENU_BG]

//let MKREADER_COLOR_1_SELECTED:UIColor = RGBA(255, 117, 54)
//let MKREADER_COLOR_2_SELECTED:UIColor = RGBA(185, 132, 23)
//let MKREADER_COLOR_3_SELECTED:UIColor = RGBA(177, 98, 55)
//let MKREADER_COLOR_4_SELECTED:UIColor = RGBA(52, 140, 96)
//let MKREADER_COLOR_5_SELECTED:UIColor = RGBA(255, 117, 54)

//let MKREADER_SELECTED_COLORS:[UIColor] = [MKREADER_COLOR_1_SELECTED,
//                                          MKREADER_COLOR_2_SELECTED,
//                                          MKREADER_COLOR_3_SELECTED,
//                                          MKREADER_COLOR_4_SELECTED,
//                                          MKREADER_COLOR_5_SELECTED]

//let MKREADER_COLOR_1_UNSELECT:UIColor = RGBA(190, 190, 190)
//let MKREADER_COLOR_2_UNSELECT:UIColor = RGBA(225, 201, 173)
//let MKREADER_COLOR_3_UNSELECT:UIColor = RGBA(225, 201, 173)
//let MKREADER_COLOR_4_UNSELECT:UIColor = RGBA(150, 160, 130)
//let MKREADER_COLOR_5_UNSELECT:UIColor = RGBA(112, 112, 112)

//let MKREADER_UNSELECT_COLORS:[UIColor] = [MKREADER_COLOR_1_UNSELECT,
//                                          MKREADER_COLOR_2_UNSELECT,
//                                          MKREADER_COLOR_3_UNSELECT,
//                                          MKREADER_COLOR_4_UNSELECT,
//                                          MKREADER_COLOR_5_UNSELECT]

//let MKREADER_COLOR_1_INPUT_FIELD:UIColor    = RGBA(230, 230, 230)
//let MKREADER_COLOR_2_INPUT_FIELD:UIColor    = RGBA(255, 234, 213)
//let MKREADER_COLOR_3_INPUT_FIELD:UIColor    = RGBA(224, 200, 173)
//let MKREADER_COLOR_4_INPUT_FIELD:UIColor    = RGBA(191, 210, 193)
//let MKREADER_COLOR_5_INPUT_FIELD:UIColor    = RGBA(126, 126, 126)

//let MKREADER_INPUT_FIELD_COLORS:[UIColor] = [MKREADER_COLOR_1_INPUT_FIELD,
//                                             MKREADER_COLOR_2_INPUT_FIELD,
//                                             MKREADER_COLOR_3_INPUT_FIELD,
//                                             MKREADER_COLOR_4_INPUT_FIELD,
//                                             MKREADER_COLOR_5_INPUT_FIELD]
